﻿using OneSpider.Helper;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace OneSpider.API
{
    public class HttpBaseService
    {
        private static HttpClient httpClient = new HttpClient();

        public static async Task<string> GetJsonAsync(string uri)
        {
            try
            {
                string response = await httpClient.GetStringAsync(uri);
                return response;
            }
            catch (Exception e)
            {
                LogHelper.WriteLine(e);
                throw e;
            }
        }

        public static async Task<string> GetAsync(string uri)
        {
            try
            {
                string response = await httpClient.GetStringAsync(uri);
                return response;
            }
            catch (Exception e)
            {
                LogHelper.WriteLine(e);
                throw e;
            }
        }
    }
}
